package com.imooc.study.imoocstudy.aop.controller;

import com.imooc.study.imoocstudy.tkmybatis.entity.User;
import com.imooc.study.imoocstudy.tkmybatis.mapper.UserMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserController {
    @RequestMapping("/first")
    public Object first() {
        return "first controller";
    }

    @RequestMapping("/doError")
    public Object error() {
        return 1 / 0;
    }

    @Resource
    private UserMapper userMapper;

    @GetMapping("/hellTest")
    public String helloName(){

        List<User> lists = userMapper.selectAll();

        return "hello~"+lists.get(0).getName();
    }
}
